import request from './request' // 请求函数
import type {
  BannerReponse,
  CommentPlaylistReponse,
  DragonReponse,
  LyricResponse,
  PersonalizedResponse,
  PlaylistDetailResponse,
  radarResponse,
  SearchAdviceParams,
  SearchAdviceResponse,
  SearchHotsResponse,
  SearchResultResponse,
  SongUrlResponse,
  SongDetailResponse
} from './type' // 类型

// 首页-banner
export const bannerApi = () => request<BannerReponse>({ url: '/banner' })
// 首页-发现-圆形图标入口列表
export const dragonApi = () => request<DragonReponse>({ url: '/homepage/dragon/ball' })
// 首页-推荐歌单
export const personalizedApi = ({ limit }: { limit: number }) => {
  return request<PersonalizedResponse, { limit: number }>({ url: '/personalized', data: { limit } })
}
// 首页-你的雷达歌单
export const radarApi = () => {
  return request<radarResponse, { refresh: boolean }>({ url: '/homepage/block/page', data: { refresh: true } })
}
// 搜索-搜索热门
export const searchHotsApi = () => request<SearchHotsResponse>({ url: '/search/hot/detail' })
// 搜索-搜索建议
export const searchAdviceApi = (keywords: string, type = 'mobile') => request<SearchAdviceResponse, SearchAdviceParams>({ url: '/search/suggest', data: { keywords, type } })
// 搜索-搜索建议
export const searchResultApi = (keywords: string) => request<SearchResultResponse, { keywords: string }>({ url: '/search', data: { keywords } })
// 歌单-歌单详情
export const playlistDetailApi = (id: string | number) => request<PlaylistDetailResponse, { id: string | number }>({ url: '/playlist/detail', data: { id } })
// 评论-歌单详情
export const commentPlaylistApi = (id: string | number) => request<CommentPlaylistReponse, { id: string | number }>({ url: '/comment/playlist', data: { id } })
// 歌曲url
export const songUrlApi = (id: string | number) => request<SongUrlResponse, { id: string | number }>({ url: '/song/url', data: { id } })
// 歌词
export const lyricApi = (id: string | number) => request<LyricResponse, { id: string | number }>({ url: '/lyric', data: { id } })
// 获取歌曲详情
export const songDetailApi = (ids: string | number) => request<SongDetailResponse, { ids: string | number }>({ url: '/song/detail', data: { ids } })
// 获取歌曲评论
export const commentSongApi = (id: string | number) => request<CommentPlaylistReponse, { id: string | number }>({ url: '/comment/music', data: { id } })
